package validation;

import utility.cardHelper;
import card.*;

/**
 * Card Combination - Solo
 * Valid:	3, 4, 5
 * Invalid:	33, 4-5-6
 * 
 */
public class Solo extends Type{
	
	/**
	 *  Private Constructor
	 *  Set instance to null(default)
	 */
	private static Solo instance;
	
	/**
	 * Implementation of Singleton
	 * @return Type instance
	 */
	private Solo(){
		super();
		instance = null;
	}
	
	public static Type getInstance(){
		if(instance == null){
			instance = new Solo();
		}
		return instance;	
	}
	
	@Override
	public void clear(){
		instance = null;
	}
	
	@Override
	public int getPriority(Cardset hand){
		// TODO Auto-generated method stub
		return cardHelper.value2priority(hand.getCard(0).getValue());
	}

	@Override
	public Type identify(Cardset thisHand) {
		// TODO Auto-generated method stub
		boolean isValid = false;
		int n = thisHand.count();
		if(n == 1){
			isValid = true;
		}
		
		if(isValid)
			return getInstance();
		else
			return null;
	}

}
